package com.link2room.blaster.controller.inside;

import com.link2room.blaster.dto.innerUse.SMSAuthCodeParamDto;
import com.link2room.blaster.dto.innerUse.VerifyCodeParamDto;
import com.link2room.blaster.dto.result.SMSAuthCodeResDto;

import com.link2room.blaster.facade.ISMSCodeFacadeService;
import com.link2room.common.dto.result.base.BaseResultDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * Created by LN on 2017/4/19.
 */
@Api(tags = "短信验证码相关")
@RequestMapping("/in/SMSVerifyCodes")
@RestController
public class SMSVerifyCodeInsideController {
    @Resource
    private ISMSCodeFacadeService smsCodeFacadeService;

    @ApiOperation(value = "短信发送获取验证码",response = SMSAuthCodeResDto.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(value = "paramDto",paramType = "body",dataTypeClass = SMSAuthCodeParamDto.class,required = true)
    })
    @RequestMapping(value = "/send",method = RequestMethod.POST)
    public @ResponseBody
    BaseResultDto send(
            @RequestBody SMSAuthCodeParamDto paramDto
    ) throws Exception {
        SMSAuthCodeResDto res = smsCodeFacadeService.sendSMSAuthCode(paramDto);
        BaseResultDto resultDto = new BaseResultDto();
        resultDto.setResultCode(0);
        resultDto.setResultInfo(res);
        return resultDto;
    }

    @ApiOperation(value = "短信验证码校验")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(value = "paramDto",paramType = "body",dataTypeClass = VerifyCodeParamDto.class,required = true)
    })
    @RequestMapping(value = "/verify" ,method = RequestMethod.POST)
    public @ResponseBody
    BaseResultDto verifyCode(@RequestBody VerifyCodeParamDto paramDto) throws Exception {
        smsCodeFacadeService.verifyCode(paramDto);
        BaseResultDto resultDto = new BaseResultDto();
        resultDto.setResultCode(0);
        return resultDto;
    }

}
